<?php
	class Member_Model extends CI_Model {

		function __construct(){
			parent::__construct();
		}
		
		function read(){	
			$query = $this->db->get('member');
			return $query->result();
		}

		function free(){
			$this->db->where('status_member','0');
			$this->db->order_by('tgl_daftar','desc');
			$query = $this->db->get('member');
			return $query->result();
		}

		function premium(){	
			$this->db->where('status_member','2');
			$query = $this->db->get('member');
			return $query->result();
		}

		function permintaan_update(){	
			$this->db->where('status_member','1');
			$query = $this->db->get('member');
			return $query->result();
		}

		function add($data){
			$query = $this->db->insert('member', $data);
			return $query;
		}
		
		function detail($id){
			$this->db->join('provinsi','provinsi.id_provinsi = member.id_provinsi');
			$this->db->where('id_member',$id);
			$query=$this->db->get('member');
			return $query->row();
		}
		
		function update($id_member,$data){
			$this->db->where('id_member', $id_member);
			$update = $this->db->update('member', $data);
			return $update;
		}
		
		function delete($id_member){
			$this->db->where('id_member', $id_member);
			$delete = $this->db->delete('member');
			return $delete;
		}
	}
?>